namespace CSharpPro._1023;

public class Demo
{
    public void TestPrint()
    {
        // 定义一个整型数组用于测试冒泡排序
        int[] arr = { 5, 2, 9, 1, 5, 6 };
        Console.WriteLine("排序前：");
        foreach (int num in arr)
        {
            Console.Write(num + " ");
        }

        // 冒泡排序核心逻辑
        for (int i = 0; i < arr.Length - 1; i++)
        {
            for (int j = 0; j < arr.Length - 1 - i; j++)
            {
                if (arr[j] > arr[j + 1])
                {
                    // 交换两个元素的位置
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }

        Console.WriteLine("\n排序后：");
        foreach (int num in arr)
        {
            Console.Write(num + " ");
        }
    }
    
    }
    /*public void TestPrint()
    {
        int[] arr1 = new int[5];
        arr1[0] = 1;
        arr1[4] = 5;
        for (int i = 0; i < arr1.Length; i++)
        {
            Console.WriteLine(arr1[i]+"\t");
        }
        
        string[] arr2 = new string[5];
        arr2[0] = "hello";
        arr2[4] = "world";

        for (int i = 0; i < arr2.Length; i++)
        {
            Console.WriteLine(arr1[i]+"/t");
        }
        
        int[] arr3 = { 1,2,3,4,5 };
        Console.WriteLine(arr3[4]);
        
        int[,] arr4 = new int[3, 3];
        arr4[0, 0] = 1;
        arr4[1, 1] = 2;
        arr4[2, 2] = 3;

        int[,] arr5 =
        {
            { 1, 2, 3 },
            { 4, 5, 6 },
            { 7, 8, 9 }
        };

    }*/
